**************************************************
*Trade shock effects on exports and # of products*
**************************************************
* GENERATES TABLE  2 in paper
*
use temp_nonmfg,clear
eststo clear
keep if nbnc8iso2>1
keep if nbnc8_max>1
keep if theil_d1 !=.
gen lexport_int_d1 = lexport_d1 - lnbnc8iso2_d1
global depvar_d1 = "lexport_int_d1"
global nbnc8iso2_d1 "lnbnc8iso2_d1"
egen isiciso = group(isic iso2_d)
*
*FD
global clustvar "iso2_d"
eststo: reg $depvar_d1 lgdpshock6   yd* , robust cluster($clustvar)
global clustvar "firmiso"
eststo: reg $depvar_d1 ltradeshock6  yd* , robust cluster($clustvar)
global clustvar "isiciso"
eststo: reg $depvar_d1 ltradeshock6i yd* , robust cluster($clustvar)
*
global clustvar "iso2_d"
eststo: reg $nbnc8iso2_d1 lgdpshock6   yd* , robust cluster($clustvar)
global clustvar "firmiso"
eststo: reg $nbnc8iso2_d1 ltradeshock6  yd* , robust cluster($clustvar)
global clustvar "isiciso"
eststo: reg $nbnc8iso2_d1 ltradeshock6i yd* , robust cluster($clustvar)
*
log using $DIRLOG/Replication/tab-demandlocalexports_nonmfg.txt, text replace
set linesize 250
esttab, drop(yd* ) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab, drop(yd* ) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
*output the results in a tex file directly inputable in the text
esttab using $DIRLOG/Replication/tab-demandlocalexports_input_nonmfg.tex, b(%4.3f) se(%4.3f)  starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)    ///
nocons drop(yd* _cons )  label tex substitute(\_ _) fragment replace nodepvars nonumbers nomtitles nogaps nolines eqlabels(none)
eststo clear
*all variables together
reg $depvar_d1 lgdpshock6 ltradeshock6 ltradeshock6i yd* , robust cluster(iso2_d)
reg $nbnc8iso2_d1 lgdpshock6 ltradeshock6 ltradeshock6i yd* , robust cluster(iso2_d)
*
log close
*
